package xyz.labmem.main.modular.app.zhgk.mapper

import org.apache.ibatis.annotations.Select
import org.springframework.stereotype.Repository
import xyz.labmem.main.modular.app.indexShow.controller.response.ColumEntiy
import xyz.labmem.main.modular.app.indexShow.controller.response.GlobalRes
import xyz.labmem.main.modular.app.indexShow.controller.response.TableEntiy
import xyz.labmem.main.modular.app.zhgk.entity.App_zhgfdywyhbsjgcjb
import xyz.labmem.main.modular.common.mapper.AppBaseMapper

/**
 * @Author lty
 * @Date 2022/2/7 14:12
 */
@Repository
interface App_zhgfdywyhbsjgcjb_Mapper : AppBaseMapper<App_zhgfdywyhbsjgcjb> {
  /*  @Select("select count(id) from \${table}")
    fun selectCountByTable(table: String): Long*/

   /* @Select("SELECT table_name,table_rows as table_comment FROM information_schema.tables where table_schema = (select database())")
    fun selectTableCount(): List<TableEntiy>*/

    @Select("\${table}")
    fun selectTableCount(table: String): List<TableEntiy>



    @Select("\${table}")
    fun selectTable(table: String) : List<GlobalRes>

    @Select("SELECT\n" +
            "\tcolumn_name as column_name,\n" +
            "\t( CASE WHEN column_key = 'PRI' THEN '是' ELSE '否' END ) AS is_pk,\n" +
            "\tordinal_position AS sort,\n" +
            "\tcolumn_comment as column_comment,\n" +
            "\tcolumn_type as column_type,\n" +
            "\t( CASE WHEN is_nullable = 'NO'  THEN '否' ELSE '是' END ) AS is_required,\n" +
            "\tdata_type as data_type,\n" +
            "\tcharacter_maximum_length as character_maximum_length\n" +
            "FROM\n" +
            "\tinformation_schema.COLUMNS \n" +
            "WHERE\n" +
            "\ttable_schema = (SELECT DATABASE()) \n" +
            "\tAND table_name = #{table} \t\t\n" +
            "ORDER BY\n" +
            "\tordinal_position")
    fun selectColumn(table: String): ArrayList<ColumEntiy>
}